import { CompileLinkDynamicForm } from "./compile-link.effect.js";
import {
  DCompiler,
  DCompilerItem2,
  DCompilerItem,
} from "./d-compiler.effect.js";
import { dTemplateCache, testCtrl } from "./d-templateCache.effect.mjs";
import { filterModuleConfig, oddItems } from "./filter-module.effect.mjs";
import { EditableField, HeroDetail, HeroList } from "./hero-app.effect.js";
import {
  myPane,
  myTabs,
  registerMyPaneHtml,
  registerMyTabHtml,
} from "./intercomponent-communication.effect.js";
import { template1, template2 } from "./ng-include.effect.js";
import { ngOnChildComponent } from "./ng-on.effect.js";
import {
  nfiRoot,
  nfiRootHtml,
  nfiToggle,
  nfiWrapper,
} from "./ng-ref-inside.effect.js";
import { myToggle } from "./ng-ref.effect.js";
import {
  EgPaneDirective,
  MultiSlotEgPaneDirective,
} from "./ng-transclude.effect.mjs";
import { myLogConfig } from "./play-decorator.effect.js";
import { playDraggableDirective } from "./play-drag.effect.js";
import { PopoverCacheCtrl, htmlPopoverCache } from "./popover.effect.js";
import { ExamServiceProvider } from "./provider-service.effect.js";
import {
  NotifyServiceFactory,
  ServiceExampleCtrl,
} from "./service-example.effect.mjs";
import { TooltipDemoCtrl } from "./tooltip.effect.js";

export { default, subRoutingBB } from "./index.mjs";

/**
 * @param {ng.IModule} app
 * @returns {void}
 */
const initDTemplateCache = (app) =>
  void app
    .run(["$templateCache", dTemplateCache])
    .controller("testCtrl", testCtrl);

__App__ && initDTemplateCache(__App__);

/**
 * @param {ng.IModule} app
 * @returns {void}
 */
const initServiceExample = (app) =>
  void app
    .controller("ServiceExampleCtrl", ServiceExampleCtrl)
    .factory("notify", NotifyServiceFactory);
__App__ && initServiceExample(__App__);

/**
 * @param {ng.IModule} app
 * @returns {void}
 */
const initNgTransclude = (app) =>
  void app
    .directive("egPane", EgPaneDirective)
    .directive("multiSlotEgPane", MultiSlotEgPaneDirective);
__App__ && initNgTransclude(__App__);

/**
 * @param {ng.IModule} app
 * @returns {void}
 */
const initFilterModule = (app) =>
  void app.config(filterModuleConfig).filter("oddItems", oddItems);
__App__ && initFilterModule(__App__);

/**
 * @param {ng.IModule} App
 * @returns {void}
 */
const initPlayDecorator = (App) => void App.config(myLogConfig);

__App__ && initPlayDecorator(__App__);

/**
 * @param {ng.IModule} app
 * @returns {void}
 */
const initNgOn = (app) =>
  void app.component(camelCase("child-component"), ngOnChildComponent);

__App__ && initNgOn(__App__);

/**
 * @param {ng.IModule} app
 * @returns {void}
 */
const initTooltip = (app) =>
  void app.controller("TooltipDemoCtrl", TooltipDemoCtrl);

__App__ && initTooltip(__App__);

/**
 * @param {ng.IModule} app
 * @returns {void}
 */
const initPopover = (app) =>
  void app
    .run(["$templateCache", htmlPopoverCache])
    .controller("PopoverCacheCtrl", PopoverCacheCtrl);

__App__ && initPopover(__App__);

/**
 * @param {ng.IModule} app
 * @returns {void}
 */
const initNgRef = (app) => void app.component("myToggle", myToggle);

__App__ && initNgRef(__App__);

/**
 * @param {ng.IModule} App
 * @returns {void}
 */
const initPlayDrag = (App) =>
  void App.directive("playDraggable", playDraggableDirective);

__App__ && initPlayDrag(__App__);

/**
 * @param {ng.IModule} app
 * @returns {void}
 */
const initDCompiler = (app) =>
  void app
    .component(camelCase("d-compiler"), DCompiler)
    .component(camelCase("d-compiler-item"), DCompilerItem)
    .component(camelCase("d-compiler-item2"), DCompilerItem2);
__App__ && initDCompiler(__App__);

/**
 * @param {ng.IModule} app
 * @returns {void}
 */
const initCompileLink = (app) =>
  void app.directive(camelCase("dynamic-form"), CompileLinkDynamicForm);
__App__ && initCompileLink(__App__);

/**
 * @param {ng.IModule} app
 * @returns {void}
 */
const initProviderService = (app) => void app.config(ExamServiceProvider);
__App__ && initProviderService(__App__);

/**
 * @param {ng.IModule} app
 * @returns {void}
 */
const initNgInclude = (app) =>
  void app.run([
    "$templateCache",
    /**
     * @param {ng.ITemplateCacheService} $templateCache
     */
    ($templateCache) => {
      $templateCache.put("template1.html", template1);
      $templateCache.put("template2.html", template2);
    },
  ]);
__App__ && initNgInclude(__App__);

/**
 * @param {ng.IModule} app
 * @returns {void}
 */
const initIntercomponentCommunication = (app) =>
  void app
    .run(registerMyPaneHtml)
    .run(registerMyTabHtml)
    .component("myTabs", myTabs)
    .component("myPane", myPane);

__App__ && initIntercomponentCommunication(__App__);

/**
 * @param {ng.IModule} app
 * @returns {void}
 */
const initNgRefInside = (app) =>
  void app
    .run([
      "$templateCache",
      /**
       * @param {ng.ITemplateCacheService} $templateCache
       */
      ($templateCache) => {
        $templateCache.put("nfi-root.html", /* HTML */ nfiRootHtml);
      },
    ])
    .component("nfiRoot", nfiRoot)
    .component("nfiToggle", nfiToggle)
    .component("nfiWrapper", nfiWrapper);

__App__ && initNgRefInside(__App__);
/**
 * @param {ng.IModule} app
 * @returns {void}
 */
const initHeroApp = (app) =>
  void app.component({
    heroList: HeroList,
    heroDetail: HeroDetail,
    editableField: EditableField,
  });

__App__ && initHeroApp(__App__);
